| 1. | To obtain the player instance , you must call a static factory method of the 要获得播放器实例,则必须在 |
| 2. | One advantage of static factory methods is that , unlike constructors , they have names 静态工厂方法的一个好处是,与构造函数不同,静态工厂方法具有名字。 |
| 3. | A third advantage of static factory methods is that , unlike constructors , they can return an object of any subtype of their return type 第三个好处是,与构造函数不同,它们可以返回一个原返回类型的子类型的对象。 |
| 4. | In summary , static factory methods and public constructors both have their uses , and it pays to understand their relative merits 总而言之,静态工厂方法和构造函数均有各自的适用性,掌握他们不同的适用场所是很有用的。 |
| 5. | For example , the static factory method boolean . valueof ( string ) is almost always preferable to the constructor boolean ( string ) 为了避免造成重复创建对象,如果一个类提供了静态的方法来创建对象,最好是优先使用静态方法。 |
| 6. | A second advantage of static factory methods is that , unlike constructors , they are not required to create a new object each time they ' re invoked 第二个好处是,与构造函数不同,它们每次被调用的时候,不要求非得创建一个新的对象。 |
| 7. | You can often avoid creating duplicate objects by using static factory methods in preference to constructors on immutable classes that provide both 对于同时提供了静态工厂方法和构造函数的非可变类,通常可以用静态工厂方法而不是构造函数来避免创建重复的对象。 |